<?php
namespace app\agent\controller;

use app\common\controller\AgentAction;

class Goods extends AgentAction
{
	protected $modelClass = '\app\common\model\Goods';

	public function initialize()
    {
        parent::initialize();
    }

    public function index(){
    	$where[] = ['uid','=',UID];
        if (input('get.search')){
            $where[] = ['name', 'like', '%'.input('get.search').'%'];
        }
        if (input('get.status')) {
            if (input('get.status') == 1) {
                $where[] = ['status', '=', '1'];
            }else{
                $where[] = ['status', '=', '0'];
            }
        }
        if (input('get._sort')){
            $order = explode(',', input('get._sort'));
            $order = $order[0].' '.$order[1];
        }else{
            $order = 'sort asc,id asc';
        }
        $dataList = $this->cModel->where($where)->order($order)->paginate('', false, page_param());
        $this->assign('dataList', $dataList);
        return $this->fetch();
    }
}